package com.fuchen.academic.convertor;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;

import com.fuchen.academic.util.StringUtil;

public class DateConvertor implements Converter<String, Date> {

	private static final String format = "yyyy-MM-dd HH:mm:ss";
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat(format);
	
	@Override
	public Date convert(String arg0) {

		if(StringUtil.isNotEmpty(arg0)){
			try {
				return dateFormat.parse(arg0);
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}

		return null;
	}

}
